package com.tpo;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ListView;

import com.tpo.*;


public class tpoAndroidActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
    }
    
    public void verTiempo(View view) {
    	final AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
    	final AlertDialog.Builder alt_bld2 = new AlertDialog.Builder(this);
    	Resources res = getResources();
    	TextView lblTemperatura = (TextView)findViewById(R.id.lblTemperatura);
    	EditText boxCiudad = (EditText)findViewById(R.id.box_Ciudad);
 
    	weather we = new weather(); //Este objeto obtiene el clima
    	    	
    	String reemplazar=new String();
    	reemplazar= boxCiudad.getText().toString();
    	we.ciudad =reemplazar.replace(" ","+");
    	we.setConf(we.ciudad,res.getString(R.string.lbl_Lang));
    	we.getXML();

    	Tiempo t=new Tiempo();
    	/*
    	lblTemperatura.setText("Estado:"+we.condicion+
    							"\nTemperatura: "+we.temperatura+"C\n"+
    							we.humedad+"\nHora: "+t.mostrarHoraConcatenada());
    	*/
    	String datos = res.getString(R.string.lbl_Estado)+":"+we.condicion+
				"\n"+res.getString(R.string.lbl_Temperatura)+": "+we.temperatura+"C\n"+
				we.humedad+"\n"+res.getString(R.string.lbl_Hora)+": "+t.mostrarHoraConcatenada();
    	
      	Intent intent = new Intent(this, MapaActivity.class);
    	intent.putExtra("ciudad",reemplazar);
    	intent.putExtra("data",datos);
      	
    	startActivity(intent);
    	
    }
    
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
    	//animate();
    	super.onWindowFocusChanged(hasFocus);
    }
    
    private void animate(){
    	/*
    	ImageView imgView = (ImageView)findViewById(R.id.imagen);
    	imgView.setVisibility(ImageView.VISIBLE);
    	imgView.setBackgroundResource(R.drawable.frame_animation);
    	
    	AnimationDrawable frame = (AnimationDrawable) imgView.getBackground();
    	if(frame.isRunning()){
    		frame.stop();
    	}else{
    		frame.stop();
    		frame.start();
    	}
    	*/
    } 
    
    
}